<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>厂商批号选择</title>
<meta name="decorator" content="default"/>
<script src="${ctxStatic}/common/change/change.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	initVaccName(bsVaccineBatchno.companyCode,bsVaccineBatchno.vaccineId);
	$(".vaccineCompany").change(function(){
		initCompanyName($(this).val());
	});
});
var bsVaccineBatchno = JSON.parse('${fns:toJson(bsVaccineBatchno)}');
function page(n,s){
	$("#pageNo").val(n);
	$("#pageSize").val(s);
	$("#searchForm").submit();
    return false;
}

function add(){
	location.href="${ctx}/vaccinate/bsVaccineBatchno/addForm?batchType=1";
}
function addSyringe(){
	location.href="${ctx}/vaccinate/bsVaccineBatchno/addForm?batchType=2";
}

$(document).on("click","#union",function(){
	debugger;
	var outBoundDate = $(this).parent().parent().attr("data-outBoundDate");
	var spec = $(this).parent().parent().attr("data-spec");
	var obj = {
			batchnoId : $(this).parent().parent().attr("data-id"),
			spec : spec,
			outBoundDate : outBoundDate,
			batchType : $(this).parent().parent().attr("data-batchType"),
			ccode : $(this).parent().parent().attr("data-companyCode"),
			vcode : $(this).parent().parent().attr("data-vaccineId")
		};
	if(outBoundDate == '' || outBoundDate == '-' || spec == '' || spec == '-'){
		layer.msg("该批号的有效日期或规格的格式不正确!");
		return;
	}
	window.parent.getInfo(obj);
});

function closeLayer(){
	var index=parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}
</script>
<style type="text/css">
body{
   padding:10px;
}		
#contentTable td ,#contentTable th{
	text-align: center;
	padding:1px 10px;
}
.minWidth {
	min-width: 177px;
}
</style>
</head>
<body>
	<form:form id="searchForm" modelAttribute="bsVaccineBatchno" action="${ctx}/vaccinate/bsVaccineBatchno/getCompanyBathnoList" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input id="companyCode" name="companyCode" type="hidden" value="${bsVaccineBatchno.companyCode}"/>
		<table class="table table-bordered">
			<tr>
			    <th>疫苗/注射器:</th>
				<td>
					<form:select path="batchType" id="batchType" class="span2 minWidth" >
						<form:option value="" label="--请选择--"/>
						<form:options items="${fns:getDictList('batch_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
				</td>
				<th>疫苗类型:</th>
				<td>
					<form:select path="type" id="type" class="span2 minWidth" >
						<form:option value="" label="--请选择--"/>
						<form:options items="${fns:getDictList('bs_vaccineInfo_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
				</td>
				<th>疫苗批号：</th>
				<td>
					<form:input path="batchno" id="batchno" class="span2 minWidth" />	
				</td>
			</tr>
			<tr>
			    <th>疫苗名称:</th>
				<td>
					<form:select path="vaccineId" id="vaccineId" class="span2 minWidth vaccineCompany" >
						<form:option value=""  label="--请选择--"/>
					</form:select>
				</td>
				<td><span>有效期情况</span></td>
			    <td colspan="3">
				    <form:radiobuttons path="dateType" items="${fns:getDictList('dateType')}" itemLabel="label" itemValue="value"/>
				</td>
			</tr>
		</table>
		<div>
			<button id="s" class="btn btn-primary" type="submit"> <!-- <i class="icon-search"></i> -->查询</button>
			<button id="" class="btn btn-primary" onclick="closeLayer()" type="button">关闭窗口</button>
		</div>
	</form:form>
	
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed" >
		<thead>
			<tr>
				<th>操作</th>
				<th>疫苗名称</th>
				<th>疫苗生产企业</th>
				<th>疫苗批号</th>
				<th>有效日期</th>
				<th>规格</th>
				<th>剂量</th>
				<th>批签发合格证明编号</th>
			</tr>
		</thead>
		<tbody id="tbody">
		<c:forEach items="${page.list}" var="bsVaccineBatchno">
			<tr data-vaccineId="${bsVaccineBatchno.vaccineId}" data-companyCode="${bsVaccineBatchno.companyCode}" data-id="${bsVaccineBatchno.id}" data-batchType="${bsVaccineBatchno.batchType}" 
			data-outBoundDate="${bsVaccineBatchno.outBoundDate}" data-spec="${bsVaccineBatchno.spec}">
				<td>
					<input type="button" style="border:none;background-color:#ffffff;" id="union" value="关联"/>
				</td>
				<td>
					${bsVaccineBatchno.vaccineName}
				</td>
				<td>
					${bsVaccineBatchno.companyName}
				</td>
				<td>
				    ${bsVaccineBatchno.batchno}
					<c:if test="${not empty bsVaccineBatchno.secondBatchno}">
				        <span title="(查询批号时不需要带入亚批号)" style="color: #2fa4e7;">-${bsVaccineBatchno.secondBatchno}</span>
				    </c:if>
				</td>
				<td>
				<fmt:formatDate value="${bsVaccineBatchno.outBoundDate}" pattern="yyyy-MM-dd"/>
				</td>
				<td>
					${bsVaccineBatchno.spec}
				</td>
				<td>
					${bsVaccineBatchno.dose}
				</td>
				<td>
					${bsVaccineBatchno.certifiCode}
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>